package com.qeegoo.b2bautozityp.api;


import com.qeegoo.b2bautozityp.BuildConfig;
import com.qeegoo.b2bautozityp.constant.Constants;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;


/**
 * Created by 王少岩 on 2016/9/14.
 */
public class HttpParams {

    /**
     * 登录
     *
     * @param username
     * @param password
     * @return
     */
    public static Map<String, String> userLogin(String username, String password) {
        Map<String, String> map = new HashMap<>();
        map.put("username", username);
        map.put("password", password);
        return map;
    }

    /**
     * 注册
     *
     * @return
     */
    public static Map<String, String> register(String name, String loginName, String mobile, String areaId, String connector
            , String email, String address, String password, String confirmPassword) {
        Map<String, String> map = new HashMap<>();
        map.put("name", name);
        map.put("loginName", loginName);
        map.put("mobile", mobile);
        map.put("areaId", areaId);
        map.put("connector", connector);
        map.put("email", email);
        map.put("address", address);
        map.put("password", password);
        map.put("confirmPassword", confirmPassword);
        return map;
    }

    /**
     * 分类列表
     *
     * @param parentId
     * @return
     */
    public static Map<String, String> goodsCategory(String parentId) {
        Map<String, String> map = new HashMap<>();
        map.put("parentId", parentId);
        return map;
    }

    /*
        询价列表
     */
    public static Map<String, String> showAskPriceOrderList(String pageNo, String pageSize, String scopeStatus) {
        Map<String, String> map = new HashMap<>();
        map.put("pageNo", pageNo);
        map.put("pageSize", pageSize);
        map.put("scopeStatus", scopeStatus);
        return map;
    }

    /*
        订单列表
     */
    public static Map<String, String> paramOrderLists(String pageNo, String pageSize, String tag, String words) {
        Map<String, String> map = new HashMap<>();
        map.put("pageNo", pageNo);
        map.put("pageSize", pageSize);
        map.put("tag", tag);
        map.put("words", words);
        return map;
    }

    /*
        商品列表
     */
    public static Map<String, String> paramGoodsLists(String pageNo, String pageSize, String tags, String words) {
        Map<String, String> map = new HashMap<>();
        map.put("pageNo", pageNo);
        map.put("pageSize", pageSize);
        map.put("tags", tags);
        map.put("words", words);
        return map;
    }

    /**
     * 商品详情
     *
     * @param goodsId
     * @return
     */
    public static Map<String, String> paramDetailById(String goodsId) {
        Map<String, String> map = new HashMap<>();
        map.put("goodsId", goodsId);
        return map;
    }

    /**
     * 更新商品状态
     *
     * @param goodsId
     * @param tags
     * @return
     */
    public static Map<String, String> paramUpdateGoodsStatus(String goodsId, String tags) {
        Map<String, String> map = new HashMap<>();
        map.put("goodsId", goodsId);
        map.put("tags", tags);
        return map;
    }

    /**
     * 批量上架商品
     *
     * @param goodsId 批量上架的商品Id（以逗号隔开）
     * @return
     */
    public static Map<String, String> paramUpdateBatchGoods(String goodsId) {
        Map<String, String> map = new HashMap<>();
        map.put("goodsId", goodsId);
        return map;
    }

    /**
     * 订单、退单详情、发货，收货
     *
     * @param code
     * @return
     */
    public static Map<String, String> paramViewByCode(String code) {
        Map<String, String> map = new HashMap<>();
        map.put("code", code);
        return map;
    }


    public static Map<String, String> goodsCategoryBykeyWords(String keyWords) {
        Map<String, String> map = new HashMap<>();
        map.put("keyWords", keyWords);
        return map;
    }

    /**
     * 商品图片上传
     *
     * @param goodsId
     * @param file
     * @return
     */
    public static Map<String, RequestBody> uploadImage(String goodsId, File file) {
        RequestBody type_body = RequestBody.create(MediaType.parse("text/plain"), goodsId);
        Map<String, RequestBody> map = new HashMap<>();
        map.put("goodsId", type_body);

        if (file != null) {
            RequestBody fileBody =
                    RequestBody.create(MediaType.parse("multipart/form-data"), file);
            map.put("file\"; filename=\"" + file.getName() + "", fileBody);
        }
        return map;
    }

    public static Map<String, RequestBody> uploadDetailImage(File file) {
        Map<String, RequestBody> map = new HashMap<>();
        if (file != null) {
            RequestBody fileBody =
                    RequestBody.create(MediaType.parse("multipart/form-data"), file);
            map.put("detailFile\"; filename=\"" + file.getName() + "", fileBody);
        }
        return map;
    }

    /**
     * 商品图片删除
     *
     * @param imgId
     * @return
     */
    public static Map<String, String> deleteImage(String imgId) {
        Map<String, String> map = new HashMap<>();
        map.put("imgId", imgId);
        return map;
    }

    /**
     * 获取品牌
     *
     * @param keyWords
     * @return
     */
    public static Map<String, String> goodsBrandBykeyWords(String keyWords) {
        Map<String, String> map = new HashMap<>();
        map.put("keyWords", keyWords);
        return map;
    }

    /**
     * 获取车型
     *
     * @param firstLetter
     * @return
     */
    public static Map<String, String> getListCarLogo(String firstLetter) {
        Map<String, String> map = new HashMap<>();
        map.put("firstLetter", firstLetter);
        return map;
    }

    /**
     * 获取车系
     *
     * @param carLogoId
     * @return
     */
    public static Map<String, String> getListCarSeries(String carLogoId) {
        Map<String, String> map = new HashMap<>();
        map.put("carLogoId", carLogoId);
        return map;
    }

    /**
     * 获取年款排量
     *
     * @param seriesIds
     * @return
     */
    public static Map<String, String> getListCarYear(String seriesIds) {
        Map<String, String> map = new HashMap<>();
        map.put("seriesIds", seriesIds);
        return map;
    }

    /**
     * 根据车系及年款获取所有车型获取车型
     *
     * @param seriesIds
     * @param carYear
     * @return
     */
    public static Map<String, String> getListCarModel(String seriesIds, String carYear, String capacity) {
        Map<String, String> map = new HashMap<>();
        map.put("seriesIds", seriesIds);
        map.put("carYear", carYear);
        map.put("capacity", capacity);
        return map;
    }

    /**
     * 保存商品
     *
     * @param id             商品ID 编辑的时候必填
     * @param productType    配件品质:30:原厂 40:国际品牌 50:国产品牌 70:拆车
     * @param oemCode        OEM码
     * @param oemName        商品名字
     * @param quantity       商品数量
     * @param warehouseId    仓库id
     * @param productId      类目ID
     * @param brandId        商品品牌Id
     * @param mids           车型id集合字符串 mids,多个用','分割,不要多空格
     * @param goodsRemark    商品备注
     * @param goodsUnitId    商品单位Id
     * @param goodsStyle     商品规格型号
     * @param serialNumber   商品出厂编码
     * @param productQuality 60:6成新 70:7成新 80:8成新 90:9成新 100:全新
     * @param general        是否为通用车型0:否 1:是
     * @param showTag        是否展示在商城0:否 1:是
     * @param invoiceTag     是否能开发票0:否 1:是
     * @param goodsType      商品类型：(0:积压,:1:全新件,2 拆车件)
     * @param unitPrice
     * @param settlePrice
     * @param tradePrice
     * @param status         9:上架(保存上架) 8:下架(保存)
     * @param imageIds       图片id，多个逗号隔开
     * @param imageUrls      图片临时地址串，用逗号隔开，与imageIds串要一一对应
     * @param imageRowNums   图片序顺号拼接字符串，用逗号隔开，与imageIds串要一一对应，顺序号为1-5 五张图顺序
     * @param goodsDetails   传的格式需要带<img>标签 例: <img src="http://jyj.autozie.com/images/detail-content.png" />
     * @return
     */
    public static Map<String, String> saveGoods(String id, String productType, String oemCode, String oemName, String quantity, String warehouseId, String productId,  String brandId,
                                                String mids, String goodsRemark, String goodsUnitId, String goodsStyle, String serialNumber, String productQuality, String general, String showTag, String invoiceTag,
                                                String goodsType, String unitPrice, String settlePrice, String tradePrice,
                                                String status, String imageIds, String imageUrls, String imageRowNums, String goodsDetails) {
        Map<String, String> map = new HashMap<>();
        map.put("id", id);
        map.put("productType", productType);
        map.put("oemCode", oemCode);
        map.put("oemName", oemName);
        map.put("quantity", quantity);
        map.put("warehouseId", warehouseId);
        map.put("productId", productId);
        map.put("brandId", brandId);
        map.put("mids", mids);
        map.put("goodsRemark", goodsRemark);
        map.put("goodsUnitId", goodsUnitId);
        map.put("goodsStyle", goodsStyle);
        map.put("serialNumber", serialNumber);
        map.put("productQuality", productQuality);
        map.put("general", general);
        map.put("showTag", showTag);
        map.put("invoiceTag", invoiceTag);
        map.put("goodsType", goodsType);
        if (invoiceTag.equals("0")) {
            map.put("unitPriceNoInvoice", unitPrice);
            map.put("settlePriceNoInvoice", settlePrice);
            map.put("tradePriceNoInvoice", tradePrice);
        } else {
            map.put("unitPrice", unitPrice);
            map.put("settlePrice", settlePrice);
            map.put("tradePrice", tradePrice);
        }
        map.put("status", status);
        map.put("warehouseId", warehouseId);
        map.put("oemCode", oemCode);
        map.put("imageIds", imageIds);
        map.put("imageUrls", imageUrls);
        map.put("imageRowNums", imageRowNums);
        map.put("goodsDetails", goodsDetails);
        return map;
    }

     /*
         检查更新接口
      */
    public static  Map<String,String> getMobileCheckupdateUrl(){
        HashMap<String, String> map = new HashMap<>();
        map.put("m","MobileSystem");
        map.put("a","checkVersion");
        map.put("project_id", Constants.sProjectId);
        map.put("ctype","2");
        map.put("cur_version", BuildConfig.VERSION_NAME+"");
        return map;
    }

}
